use strict;
use File::Find;
use Cwd;
my $dir = shift or die "Please input a directory!!!";
my $mode = shift;

find (\&handle,$dir);
sub handle{
	my $file_path = $File::Find::name;
	my $file_name = $_;
	if( $file_name =~ /\.html$/){
		
		open SRC_FILE ,"$file_name" or die "can not open $file_name:$!";
		open TMP_FILE ,">$file_name.tmp" or die "can not open $file_name:$!";
				
		while(<SRC_FILE>){
			chomp;
			my $row = $_;

			if($mode eq "d"){
				if( $row =~ /(.*src="cuc:\/\/.*) | (.*href="cuc:\/\/.*)/ ){
					$row = "<!--" . $row . "     -->";
				}
				if($row =~ /^<!--$/){
					$row = '';
				}
			}
			if($mode eq "e"){
				if( $row =~ /.*href="cuc:\/\/.*/ ){
					$row = "<!--" . $row . "     -->";
				}

			}			
			print TMP_FILE $row ."\n";
		}
		print $file_name . "\n";	
		close SRC_FILE;	
		close TMP_FILE;
	}
	
}